package com.nhimeye.domain;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.ManyToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.springframework.roo.addon.equals.RooEquals;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.entity.RooJpaEntity;
import org.springframework.roo.addon.serializable.RooSerializable;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaEntity(table = "secUser")
@RooEquals
@RooSerializable
public class User {

    @NotNull
    @Size(max = 25)
    private String userName;

    @NotNull
    @Size(max = 16)
    private String password;

    @NotNull
    @Size(max = 25)
    private String firstName;

    @Size(max = 25)
    private String lastName;

    @NotNull
    @Pattern(regexp = "[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+")
    private String email;

    @Size(max = 15)
    private String phone;

    @NotNull
    private Boolean active;

    @NotNull
    private Boolean fromLdap;

    @ManyToMany(cascade = CascadeType.ALL, mappedBy = "users")
    private Set<Group> groups = new HashSet<Group>();

    @ManyToMany(cascade = CascadeType.ALL)
    private Set<Role> roles = new HashSet<Role>();
}
